<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 100px;
            height: 100px;
            background: red;
        }

        .box::after {
            content: '';
            width: 50px;
            height: 50px;
            background: yellow;
            display: block;
        }
    </style>
</head>

<body>
    <div class="box"></div>
    <script>
        // 获取行间样式  style  
        // 非行间样式
        var boxEle = document.querySelector(".box");
        // console.log(boxEle.style.background);
        //1. chrome :getComputedStyle(元素,'获取伪类的样式默认是null')[样式名称];
        // var res = window.getComputedStyle(boxEle,'after')['width'];
        // console.log(res);
        // 2.IE :currentStyle  元素.currentStyle.样式名称
        // 
        //    var res =   boxEle.currentStyle.width;
        //    console.log(res);
        if (window.getComputedStyle) {
            var res = getComputedStyle(boxEle)['width'];
            console.log(res);
        } else {
            var res = boxEle.currentStyle.width;
            console.log(res);
        }


    </script>
</body>

</html>